package de.wellenblau.slideshow
{
	import caurina.transitions.Tweener;
	
	import flash.display.Bitmap;
	
	public class MoveLeftSlideshow extends AbstractSlideshow
	{
		//config especially for this fade or tween
		private var _currentImage:Bitmap;
		
		//tweenConfig
		private var _fadeOutTime:uint;
		private var _fadeOutDelay:Number;
		private var _fadeOutTransition:String;
		
		public function MoveLeftSlideshow()
		{
			super();
		}
		
		override protected function initConfig():void{
			//faderconfig
			_fadeOutTime = _config.fadeout.@time;
			_fadeOutDelay = _config.fadeout.@delay;
			_fadeOutTransition = _config.fadeout.@transition;
		}
		
		override protected function loadingComplete():void{
			//add the current image to the que
			if(_currentImage != null){
				_currentImage.alpha=0;
				_currentImage.x=0;
				_images.push(_currentImage);
			}
			//shift the next image out of the que
			_currentImage = _images.shift();
			
			//dispaly the current image
			_images[0].alpha=1;
			_currentImage.alpha=1;
			addChild(_images[0]);
			addChild(_currentImage);
				
			Tweener.addTween(
				_currentImage, //fade in the current image
				{
					x:_currentImage.width, 			//tween it out
					time:_fadeOutTime,				//tweentime
					delay:_fadeOutDelay,			//how long should the current image stay at x y 0
					transition:_fadeOutTransition, 	//which transition
					onComplete:function():void{		// after the fade out -> fade in the next image
						loadingComplete();
					}
				}
			);
			
			//Tween end
		}
		
	}
}